package com.myhexin.business;

import com.myhexin.alert.AlertServiceProviderFactory;
import com.myhexin.alert.spi.AlertService;
import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Jayce
 * @version 1.0.0
 * @date 2021/10/6
 * @desc 业务实现类
 */
@Slf4j
public class BusinessService {
    public void doBusiness(String data) {
        log.info("【业务实现】开始");
        if (data == null || data.contains("error")) {
            List<AlertService> alertServiceList = AlertServiceProviderFactory.getAlertServiceProviders();

            List<String> receivers = new ArrayList<>();
            receivers.add("zhangsan");
            receivers.add("lisi");
            if (alertServiceList != null && !alertServiceList.isEmpty()) {
                for (AlertService alertService : alertServiceList) {
                    alertService.sendAlertMsg(receivers, "线上重大bug，呼死你...呼死你");
                }
            } else {
                log.error("报警服务驱动jar包未加载");
            }
        }
        log.info("【业务实现】结束");
    }
}
